package com.zhh.nio;

import java.io.File;
import java.io.IOException;

public class DefaultSessionHandler extends SessionHandler {

    @Override
    public void messageReceived(NioSession session, Object message) {
       
        byte[] msg = (byte[])message;
        System.out.println(new String(msg));
       //  session.write("HTTP/1.1 404 Not Find\r\n");
        Response response = new Response(session);
      //  byte[] body = Util.file2ByteArray(file, false);
        	String responseStr = "It works. OK!";
            response.addHeader("Content-Length", responseStr.length() + "");
            response.writeHeader();
            session.write(responseStr);
            //session.write("hello");
            //session.write(new byte[]{-1});
       
        //session.write("-1");
//        response.writeBody("It works,OK");
        //session.close();
    }

}
